package com.itheima.d2_thread_safe;

public class Account {
    private String accountId;
    private double money;


    public Account() {
    }

    public Account(String accountId, double money) {
        this.accountId = accountId;
        this.money = money;
    }

    public String getAccountId() {
        return accountId;
    }

    public void setAccountId(String accountId) {
        this.accountId = accountId;
    }

    public double getMoney() {
        return money;
    }

    public void setMoney(double money) {
        this.money = money;
    }



    public void drawMoney(double money) {
        Thread thread = Thread.currentThread();
        String name = thread.getName();
        if (this.money >= money) {
            System.out.println(name + "取钱成功");
        } else {
            System.out.println(name + "取钱失败");
        }
    }

    @Override
    public String toString() {
        return "Account{" +
                "accountId='" + accountId + '\'' +
                ", money=" + money +
                '}';
    }
}

